package kit.views;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

import kit.persistency.KitDB;

public class ExposedCellRender extends DefaultListCellRenderer {
	private String question;
	
	public ExposedCellRender(String question) {
		this.question = question;
	}
	
	private static final long serialVersionUID = -7231951996176352573L;

	@Override
	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus ) {
		Component c = super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
		KitDB db = new KitDB();
		String answer = ((String) value).split(" ",2)[0];
		if(db.isAnswerExposed(question, answer)){
			c.setForeground(Color.RED);
		}
		return c;
	}

}
